#ifndef __PA_CMN_H__
#define __PA_CMN_H__
#include "syscore.h"
#include "../logServer/clogger.h"

#define PALogDebug(fmt, args...) CLogger(MODULE_PA, __FILE__, __LINE__, LOG_DEBUG, fmt, ##args);
#define PALogInfo(fmt, args...) CLogger(MODULE_PA, __FILE__, __LINE__, LOG_INFO, fmt, ##args);
#define PALogNotice(fmt, args...) CLogger(MODULE_PA, __FILE__, __LINE__, LOG_NOTICE, fmt, ##args);
#define PALogWarning(fmt, args...) CLogger(MODULE_PA, __FILE__, __LINE__, LOG_WARNING, fmt, ##args);
#define PALogError(fmt, args...) CLogger(MODULE_PA, __FILE__, __LINE__, LOG_ERR, fmt, ##args);
#define PALogCrit(fmt, args...) CLogger(MODULE_PA, __FILE__, __LINE__, LOG_CRIT, fmt, ##args);
#define PALogAlert(fmt, args...) CLogger(MODULE_PA, __FILE__, __LINE__, LOG_ALERT, fmt, ##args);
#define PALogEmerg(fmt, args...) CLogger(MODULE_PA, __FILE__, __LINE__, LOG_EMERG, fmt, ##args);

#define  debug_dump_buffer(num, str)  {                                \
    if( (num) > 0 )                                                    \
    {                                                                  \
        int32_t pst = 0;                                               \
        printf("DUMP BIN(%d): ", num);                                 \
        for( ; pst < num - 1; ++pst )                                  \
            printf("0x%02X,", *((unsigned char*)str + pst));           \
        printf("0x%02X\n", *((unsigned char*)str + num - 1));          \
    }                                                                  \
}

typedef enum tag_pa_ret {
    pa_ret_ok = 0,
    pa_ret_nok,
    pa_not_found,
    pa_off,
    pa_not_supported,
    pa_uart_read_zero,
    pa_err_uart,
    pa_err_uart_read,
    pa_err_uart_write,
    pa_err_magic,
    pa_err_crc,
    pa_err_mod_addr,
    pa_err_com_code,
    pa_err_cmd_size,
    pa_err_rsp_flag,
    pa_err_param,

} pa_ret_t;

typedef struct tag_mod_addr {
    uint8_t func_code;
    uint8_t addr_code;
} mod_addr_t;

typedef struct tag_lpa_status {
    uint8_t pa_switch;
    int8_t pa_temp;
    uint8_t pa_upatt;
    uint8_t pa_dnatt;
    int8_t pa_dn_power;
    int16_t pa_dn_10_power;
    uint8_t state;
    int8_t pa_sw10ratio;
	int8_t pa_tempthres;
	int8_t pa_powerthres;
} lpa_status_t;

#endif //__PA_CMN_H__

